//引入layout组件
import Layout from '@/layout'

// 常量路由
export const constantRoutes = [
  //登录的路由
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },
  //404的路由
  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },
  //注册的是首页的路由
  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
      path: 'dashboard',
      name: 'Dashboard',
      component: () => import('@/views/dashboard/index'),
      meta: {
        title: 'Dashboard',
        icon: 'dashboard'
      }
    }]
  },
]

// 动态路由(异步路由)
export const asyncRoutes = [
  /* 权限管理 */
  {
    name: 'Acl',
    path: '/acl',
    component: Layout,
    redirect: '/acl/user/list',
    meta: {
      title: '权限管理',
      icon: 'el-icon-lock'
    },
    children: [{
        name: 'User',
        path: 'user/list',
        component: () => import('@/views/acl/user/list'),
        meta: {
          title: '用户管理',
        },
      },
      {
        name: 'Role',
        path: 'role/list',
        component: () => import('@/views/acl/role/list'),
        meta: {
          title: '角色管理',
        },
      },
      {
        name: 'RoleAuth',
        path: 'role/auth/:id',
        component: () => import('@/views/acl/role/roleAuth'),
        meta: {
          activeMenu: '/acl/role/list',
          title: '角色授权',
        },
        hidden: true,
      },
      {
        name: 'Permission',
        path: 'permission/list',
        component: () => import('@/views/acl/permission/list'),
        meta: {
          title: '菜单管理',
        },
      },
    ]
  },

  //菜单栏
  {
    name: 'Product',
    path: '/product',
    component: Layout,
    redirect: '/product/category/list', //访问时重定向到这个路径
    meta: {
      title: '商品管理',
      icon: 'el-icon-s-shop'
    }, //菜单名字和图标
    children: [
      //分类管理路由
      {
        name: 'Category',
        path: 'category/list',
        component: () => import('@/views/product/category'), //按需引入
        meta: {
          title: '分类管理'
        }
      },
      //品牌管理路由
      {
        name: 'Trademark',
        path: 'trademark/list',
        component: () => import('@/views/product/trademark'),
        meta: {
          title: '品牌管理'
        }
      },
      //平台属性路由
      {
        name: 'Attr',
        path: 'attr/list',
        component: () => import('@/views/product/attr'),
        meta: {
          title: '平台属性'
        }
      },
      //Spu路由
      {
        name: 'Spu',
        path: 'spu/list',
        component: () => import('@/views/product/spu'),
        meta: {
          title: 'SPU'
        }
      },
      //Sku路由
      {
        name: 'Sku',
        path: 'sku/list',
        component: () => import('@/views/product/sku'),
        meta: {
          title: 'SKU'
        }
      }
    ]
  }
]

// 任意路由
export const anyRoutes = {
  path: '*',
  redirect: '/404',
  hidden: true
}
